<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<body data-genuitec-lp-enabled="false" data-genuitec-file-id="wc1-0" data-genuitec-path="/appWeb/src/main/webapp/index.jsp">
<h2 data-genuitec-lp-enabled="false" data-genuitec-file-id="wc1-0" data-genuitec-path="/appWeb/src/main/webapp/index.jsp">测试专用</h2>
<!-- 上传课程图片模块 -->
<div class="am-modal am-modal-confirm" tabindex="-1" id="uploadcImg">
  <div class="am-modal-dialog">
    <div class="am-modal-hd">上传课程图片</div>
    <div class="am-modal-bd" style="margin:10px;">
		<div style="margin-top:48px;">
			<!-- Ajax提交头像开始 -->
            <form id="addCouseImgForm" enctype="multipart/form-data" >
              <input type="file" accept="image/*" id="addCouseImg" name="file" value="选择图片"> 
            </form>
            <!-- Ajax提交模头像结束 -->
		</div>
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn cancel" data-am-modal-cancel>取消</span>
    </div>
  </div>
</div>
<!--  -->
</body>
<script src="amazeui.min.js"></script>
<script type="text/javascript">
function openImgModel(){
	$("#uploadcImg").modal({
	});
}
//图片回显--课程视频的图片
var courseImg = "";
$("#addCouseImg").on("change", function(){
	var file = this.files[0];
	courseImg = window.URL.createObjectURL(file);
	$(".CouseImg").attr("src",courseImg);		
	var form = new FormData(document.getElementById("addCouseImgForm"));
  $.ajax({
      type: "POST",  
      url:"files/fileUpload.action",  
      data:form, 
      // 下面三个参数要指定，如果不指定，会报一个JQuery的错误 
      cache: false,
      contentType: false,
      processData: false,
      async: false,  
      success: function(data) {
    	  console.log(data);
    	  alert("上传成功，图片存储路径为："+data.url);
    	  courseImg=data.url;
    	  $(".cancel").trigger("click");
      }  
  });	
});
</script>
<script>"undefined"==typeof CODE_LIVE&&(!function(e){var t={nonSecure:"60043",secure:"59884"},c={nonSecure:"http://",secure:"https://"},r={nonSecure:"127.0.0.1",secure:"gapdebug.local.genuitec.com"},n="https:"===window.location.protocol?"secure":"nonSecure";script=e.createElement("script"),script.type="text/javascript",script.async=!0,script.src=c[n]+r[n]+":"+t[n]+"/codelive-assets/bundle.js",e.getElementsByTagName("head")[0].appendChild(script)}(document),CODE_LIVE=!0);</script></html>